package com.lintf.framework.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @ system:Mac
 * @ author:lin tingfeng
 * @ data:2024/1/22 09:28
 * @ package_name:com.lintf.framework.config
 * @ project_name:mobile-project
 * @ desc:
 */
@Slf4j
@Configuration
public class RabbitMQConfig {

    private final ConnectionFactory connectionFactory;

    public RabbitMQConfig(ConnectionFactory connectionFactory) {
        this.connectionFactory = connectionFactory;
    }

    @PostConstruct
    public void init() {
        log.info("======RabbitMQ初始化中======");
        try {
            // Check if the connection factory is properly configured
            if (connectionFactory != null) {
                log.info("RabbitMQ 连接工厂已配置！");
            } else {
                log.error("RabbitMQ 连接工厂未配置！");
            }
        } catch (Exception e) {
            log.error("检查 RabbitMQ 连接工厂配置时出现异常：", e);
        }
        log.info("======RabbitMQ初始化完成======");
    }
}

